package cn.stronglink.asset.message.mq.dam.handle;


import cn.stronglink.asset.message.mq.dam.entity.GetAssetListParamsEntity;
import cn.stronglink.asset.message.mq.dam.entity.RackCodeEntity;
import cn.stronglink.asset.message.mq.dam.entity.ScreenCommandEntity;
import cn.stronglink.asset.message.mq.dam.message.MQMessageOfDAM;

public class OpenAssetListPageHandle extends AbstractAssetListPageHandle{
	private final static int PAGE_NUM = 1;
	private final static int PAGE_SIZE = 9;
	private final static short SCREEN_ID = 3;
	
	
	protected String getCommandCode() {
		return "EEB11100000003100000";
	}

	@Override
	protected void handleMessage(MQMessageOfDAM msg) {
		try {
			RackCodeEntity rackCodeEntity = (RackCodeEntity) msg.getAwsPostdata();
			if(rackCodeEntity!=null) {
				GetAssetListParamsEntity paramsEntity = new GetAssetListParamsEntity();
				paramsEntity.setRackCode(rackCodeEntity.getRackConverCode());
				paramsEntity.setPageNum(PAGE_NUM);
				paramsEntity.setPageSize(PAGE_SIZE);
				super.sendCommandToDam(paramsEntity, SCREEN_ID);
			}
		}catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public boolean isHandle(MQMessageOfDAM msg) {
		if(msg.getActioncode().equals(ACTION_CODE)) {
			ScreenCommandEntity sc = (ScreenCommandEntity) msg.getAwsPostdata();
			if(sc.getCommand().indexOf(this.getCommandCode())==0){
				return true;
			}
		}
		return false;
	}

}
